package o;

import android.content.Intent;
import android.text.TextUtils;
import com.huawei.appgallery.wishwall.ui.cardkit.bean.WishWallDetailContentCardBean;
import com.huawei.appgallery.wishwall.ui.cardkit.bean.WishWallDetailReplyCardBean;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ddz {
    private static volatile ddz ˋ;
    private static final Object ˎ = new Object();
    private int ˏ = 0;
    private String ॱ;

    public static ddz ˏ() {
        if (ˋ == null) {
            synchronized (ˎ) {
                if (ˋ == null) {
                    ˋ = new ddz();
                }
            }
        }
        return ˋ;
    }

    public void ˋ(WishWallDetailReplyCardBean wishWallDetailReplyCardBean) {
        wishWallDetailReplyCardBean.ꜞ();
        this.ˏ = 1;
    }

    public void ˊ(cia o_cia) {
        if (o_cia == null) {
            ddu.ˊ.ˋ("WishWallDetailManager", "setAllRepliesNotAdoptable failed!!!");
            return;
        }
        List<chz> ʻॱ = o_cia.ʻॱ();
        if (ʻॱ != null) {
            for (chz o_chz : ʻॱ) {
                if (o_chz.ˏॱ() != null && o_chz.ˏॱ().equals("wishwallreplylistcard")) {
                    List<WishWallDetailReplyCardBean> ˏ = o_chz.ˏ();
                    if (ˏ != null) {
                        for (WishWallDetailReplyCardBean ˏ2 : ˏ) {
                            ˏ2.ˏ(false);
                        }
                    }
                }
            }
        }
        o_cia.ͺ();
    }

    public void ˋ(cia o_cia, String str) {
        boolean z = false;
        if (o_cia == null || TextUtils.isEmpty(str)) {
            ddu.ˊ.ˋ("WishWallDetailManager", "deleteReplyCardData failed!!!");
            return;
        }
        List<chz> ʻॱ = o_cia.ʻॱ();
        if (ʻॱ != null) {
            for (chz o_chz : ʻॱ) {
                if (o_chz.ˏॱ() != null && o_chz.ˏॱ().equals("wishwallreplylistcard")) {
                    List ˏ = o_chz.ˏ();
                    if (ˏ != null) {
                        boolean z2;
                        Iterator it = ˏ.iterator();
                        while (it.hasNext()) {
                            WishWallDetailReplyCardBean wishWallDetailReplyCardBean = (WishWallDetailReplyCardBean) it.next();
                            if (str.equals(wishWallDetailReplyCardBean.ᐝᐝ())) {
                                z = wishWallDetailReplyCardBean.ॱㆍ();
                                if (wishWallDetailReplyCardBean.ʽ()) {
                                    this.ˏ = 2;
                                }
                                it.remove();
                                z2 = z;
                                z = true;
                                if (ˏ.size() == 0) {
                                    ʻॱ.remove(o_chz);
                                } else if (z2) {
                                    ((WishWallDetailReplyCardBean) ˏ.get(ˏ.size() - 1)).ʻ(true);
                                }
                            }
                        }
                        z2 = false;
                        if (ˏ.size() == 0) {
                            ʻॱ.remove(o_chz);
                        } else if (z2) {
                            ((WishWallDetailReplyCardBean) ˏ.get(ˏ.size() - 1)).ʻ(true);
                        }
                    }
                }
            }
        }
        ˋ(o_cia);
        if (z) {
            o_cia.ͺ();
        }
    }

    public WishWallDetailContentCardBean ˎ(cia o_cia) {
        if (o_cia == null) {
            ddu.ˊ.ˋ("WishWallDetailManager", "getDetailContentCard failed!!!");
            return null;
        }
        List ʻॱ = o_cia.ʻॱ();
        if (ʻॱ == null || ʻॱ.size() <= 0) {
            return null;
        }
        chz ˏ = o_cia.ˏ(0);
        if (ˏ.ˏॱ() == null || !ˏ.ˏॱ().equals("wishwalldetailcard")) {
            return null;
        }
        WishWallDetailContentCardBean wishWallDetailContentCardBean = (WishWallDetailContentCardBean) ˏ.ˋ(0);
        this.ॱ = wishWallDetailContentCardBean.ॱ();
        return wishWallDetailContentCardBean;
    }

    public void ˋ(cia o_cia) {
        if (o_cia == null) {
            ddu.ˊ.ˋ("WishWallDetailManager", "addEmptyCardChunkIfNeeded failed!!!");
            return;
        }
        List ʻॱ = o_cia.ʻॱ();
        if (ʻॱ != null && ʻॱ.size() == 1) {
            chz ˏ = o_cia.ˏ(0);
            if (ˏ.ˏॱ() != null && ˏ.ˏॱ().equals("wishwalldetailcard")) {
                List arrayList = new ArrayList();
                arrayList.add(new dee());
                o_cia.ˋ(10108800, cib.ˏ("wishwallemptycard"), 1, arrayList);
            }
        }
    }

    public void ॱ() {
        if (this.ॱ == null) {
            ddu.ˊ.ˋ("WishWallDetailManager", "sendReplyStateBroadcast failed, wish id is null");
            this.ˏ = 0;
            return;
        }
        Intent intent = new Intent();
        intent.setAction("action_local_brd_reply_state");
        intent.putExtra("reply_state", this.ˏ);
        intent.putExtra("wish_id", this.ॱ);
        ll.ˏ(ContentManager.getInstant().getContext()).ˋ(intent);
        this.ˏ = 0;
    }
}
